<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>判断成绩等级</title>
		<script>
			//接收用户键盘输入的框
			//var score = prompt("请您输入分数:");
			
			//定义函数
			function checkScore(){
				//根据id获取文本输入框对象,再获取文本输入框中的值
				var score = document.getElementById("score").value;
				//判断
				var result;
				if (score >= 0 && score <= 100) {
					if (score < 60) {
						result = '不及格';
					} else if (score < 70) {
						result = '及格';
					} else if (score < 90) {
						result = '良好';
					} else {
						result = '优秀';
					}
				} else {
					result = "成绩不合法";
				}
				//把结果设置回文本输入框中
				document.getElementById("score").value = result;
			}
		</script>
	</head>
	<body>
		<input type="text" id="score"/>
		<!-- 点击按钮,触发函数 -->
		<input type="button" value="验证" onclick="checkScore()"/>
	</body>
</html>
